package org.s3.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.s3.project.entity.Orderss;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author cfx
 * @version 1.0
 * @Description
 * @date 2025/2/9 9:45
 */
@Mapper
@Repository
public interface OrderssMapper extends BaseMapper<Orderss> {
    @Select("select \n" +
            "   ab.phone, d.name,o.id as oid,\n" +
            "    od.id as order_detail_id,  \n" +
            "    o.amount,\n" +
            "    o.status,\n" +
            "    o.number as order_number,  \n" +
            "    m.name as merchant_name,   \n" +
            "    u.name as user_name,       \n" +
            "    ab.detail as user_address, \n" +
            "    o.pay_status,            \n" +
            "    od.dish_flavor,            \n" +
            "    o.estimated_delivery_time, \n" +
            "    d.image as dish_image,    \n" +
            "    d.price as dish_price,     \n" +
            "    od.number as dish_quantity,\n" +
            "    d.price * od.number as total_price, \n" +
            "    d.id as dish_id            \n" +
            "from \n" +
            "    order_detail od\n" +
            "join \n" +
            "    orders o on od.order_id = o.id\n" +
            "join \n" +
            "    merchant m on o.merchant_id = m.id\n" +
            "join \n" +
            "    user u on o.user_id = u.id\n" +
            "join \n" +
            "    address_book ab on o.address_book_id = ab.id\n" +
            "join \n" +
            "    dish d on od.dish_id = d.id\n" +
            "where \n" +
            "    o.number =#{number};")
    List <Orderss>selectOrders1(@Param("number") String number);
}
